import { FC, useState, useEffect, useMemo } from 'react';
import { format } from '../../../utils/time';

const Nav: FC = () => {
  const [value, setValue] = useState<number>(Date.now());
  useEffect(() => {
    setInterval(() => {
      setValue(Date.now());
    }, 1000)
  }, []);

  const timer = useMemo(() => {
    return format(value);
  }, [value])

  return (
    <nav className="nav">
      <div className="left">首页</div>
      <div className="right">{timer}</div>
    </nav>
  );
}

export default Nav;